<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>监听属性</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="root">
        <p style="font-size: 25px;">计数器: {{counter}}</p>
        <button @click="counter++" style="font-size: 25px;">点我</button>
    </div>
</body>
<script>
    const v = new Vue({
        data() {
            return {
                counter: 1
            }
        }
    }).$mount("#root")

    v.$watch("counter", function(nval, oval) {
        alert("计数器值得变化: " + oval + "变为" + nval + "!")
    })
</script>
</html>